/* GUI CONVERTED from rsshmt.p (converter v1.76) Mon Jul 22 11:49:57 2002 */
/* rsshmt.p - Release Management Supplier Schedules- Shipper Maintenance      */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.11.1.15 $                                                     */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 7.3    LAST MODIFIED: 10/12/92           BY: WUG *G462*          */
/* REVISION: 7.3    LAST MODIFIED: 06/01/93           BY: WUG *GB46*          */
/* REVISION: 7.4    LAST MODIFIED: 01/05/94           BY: dpm *H074*          */
/* REVISION: 7.3    LAST MODIFIED: 04/20/94           BY: WUG *GJ47*          */
/* REVISION: 7.3    LAST MODIFIED: 07/15/94           BY: WUG *GK73*          */
/* REVISION: 8.5    LAST MODIFIED: 11/21/94           BY: mwd *J034*          */
/* REVISION: 8.5    LAST MODIFIED: 01/19/95           BY: taf *J038*          */
/* REVISION: 8.5    LAST MODIFIED: 03/29/95           BY: dzn *F0PN*          */
/* REVISION: 7.4    LAST MODIFIED: 05/10/95           BY: dxk *G0MC*          */
/* REVISION: 7.4    LAST MODIFIED: 08/02/95           BY: vrn *G0TF*          */
/* REVISION: 7.4    LAST MODIFIED: 12/14/95           BY: kjm *G1G8*          */
/* REVISION: 8.5    LAST MODIFIED: 02/27/96    BY: *J0CV* Robert Wachowicz    */
/* REVISION: 8.5    LAST MODIFIED: 03/08/96    BY: *G1NV* Vinay Nayak-Sujir   */
/* REVISION: 8.6    LAST MODIFIED: 12/02/96    BY: *K022* Kieu Nguyen         */
/* REVISION: 8.6    LAST MODIFIED: 02/24/97    BY: *G2L4* Ajit Deodhar        */
/* REVISION: 8.6    LAST MODIFIED: 03/17/97    BY: *K080* Kieu Nguyen         */
/* REVISION: 8.6    LAST MODIFIED: 04/02/97    BY: *K09H* Vinay Nayak-Sujir   */
/* REVISION: 8.6E   LAST MODIFIED: 02/23/98    BY: *L007* Annasaheb Rahane    */
/* REVISION: 8.6E   LAST MODIFIED: 05/09/98    BY: *L00Y* Jeff Wootton        */
/* REVISION: 8.6E   LAST MODIFIED: 06/11/98    BY: *L020* Charles Yen         */
/* REVISION: 9.0    LAST MODIFIED: 03/29/99    BY: *J3BM* Reetu Kapoor        */
/* REVISION: 9.1    LAST MODIFIED: 10/25/99    BY: *N002* Bill Gates          */
/* REVISION: 9.1    LAST MODIFIED: 03/24/00    BY: *N08T* Annasaheb Rahane    */
/* REVISION: 9.1    LAST MODIFIED: 04/10/00    BY: *L0VZ* Sandeep Rao         */
/* REVISION: 9.1    LAST MODIFIED: 09/05/00    BY: *N0RF* Mark Brown          */
/* Revision: 1.11.1.9      BY: Kirti Desai        DATE: 05/22/01  ECO: *N0Y4* */
/* Revision: 1.11.1.10     BY: Jean Miller        DATE: 05/15/02  ECO: *P05V* */
/* Revision: 1.11.1.11     BY: Tiziana Giustozzi  DATE: 05/24/02  ECO: *P03Z* */
/* Revision: 1.11.1.12     BY: Jean Miller        DATE: 06/07/02  ECO: *P080* */
/* Revision: 1.11.1.14     BY: Tiziana Giustozzi  DATE: 06/17/02  ECO: *P08H* */
/* $Revision: 1.11.1.15 $  BY: Robin McCarthy     DATE: 07/15/02  ECO: *P0BJ* */

/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

{mfdtitle.i "2+ "}
{apconsdf.i}   /* PRE-PROCESSOR CONSTANTS FOR LOGISTICS ACCOUNTING */

define new shared temp-table work_sr_wkfl like sr_wkfl.
define new shared variable h_wiplottrace_procs as handle no-undo.
define new shared variable h_wiplottrace_funcs as handle no-undo.
define new shared variable ship_abs_id like abs_mstr.abs_id no-undo.
define new shared variable cont_abs_id like abs_mstr.abs_id no-undo.

define variable disp_abs_id like abs_id.
define variable abs_recid as recid.
define variable del-yn like mfc_logical.
define variable deassign like mfc_logical.
define variable old_gwt like pt_net_wt.
define variable old_nwt like pt_net_wt.
define variable old_vol like abs_vol.
define variable diff_gwt like pt_net_wt.
define variable diff_nwt like pt_net_wt.
define variable diff_vol like abs_vol.
define variable wt_conv as decimal.
define variable vol_conv as decimal.
define variable last_shipfrom as character.
define variable last_id as character.
define variable dummy_logi as logical no-undo.
define variable total_received like pod_qty_rcvd no-undo.
define variable base_amt   like pod_pur_cost no-undo.
define variable qty_to_rcv as decimal no-undo.
define variable exch_rate  like exr_rate no-undo.
define variable exch_rate2 like exr_rate no-undo.
define variable exch_ratetype like exr_ratetype no-undo.
define variable exch_exru_seq like exru_seq no-undo.
define variable warn_substruct as logical no-undo.
define variable mc-error-number like msg_nbr no-undo.
define variable use-log-acctg   as logical    no-undo.

define buffer abs_mstr_cont for abs_mstr.
define buffer abs_mstr_par for abs_mstr.

define shared variable global_recid as recid.

{rcwabsdf.i new}
{wlfnc.i} /*FUNCTION FORWARD DECLARATIONS*/

/* VALIDATE IF LOGISTICS ACCOUNTING IS TURNED ON */
{gprun.i ""lactrl.p"" "(output use-log-acctg)"}
/*GUI*/ if global-beam-me-up then undo, leave.


if is_wiplottrace_enabled() then do:
   {gprunmo.i &module="AWT" &program=""wlpl.p""
      &persistent="""persistent set h_wiplottrace_procs"""}
   {gprunmo.i &module="AWT" &program=""wlfl.p""
      &persistent="""persistent set h_wiplottrace_funcs"""}
end.

{sotmpdef.i new}


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
abs_mstr.abs_shipfrom   colon 12 label "Supplier"
   abs_mstr.abs_shp_date   colon 36
   ad_name                 at 49    no-label
   abs_mstr.abs_id         colon 12 label "Shipper ID"
   ad_line1                at 49    no-label
 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
abs_mstr.abs_shipto     colon 20 label "Ship-To"
   si_desc                 at 45    no-label
 SKIP(.4)  /*GUI*/
with frame b side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-b-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame b = F-b-title.
 RECT-FRAME-LABEL:HIDDEN in frame b = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame b =
  FRAME b:HEIGHT-PIXELS - RECT-FRAME:Y in frame b - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME b = FRAME b:WIDTH-CHARS - .5.  /*GUI*/


/* SET EXTERNAL LABELS */
setFrameLabels(frame b:handle).

for each t_all_data exclusive-lock:
   delete t_all_data.
end. /* FOR EACH t_all_data */

do for abs_mstr:

   for first abs_mstr
      fields (abs_dataset abs_gwt abs_id abs_nwt abs_par_id abs_qty
              abs_shipfrom abs_shipto abs_shp_date abs_status
              abs_type abs_vol)
      where recid(abs_mstr) = global_recid
   no-lock: end.

   if available abs_mstr and abs_id begins "s" and abs_type = "r"
   then do:

      for first ad_mstr
         fields (ad_addr ad_line1 ad_name)
         where ad_addr = abs_shipfrom
      no-lock: end.

      display
         abs_shipfrom
         substring(abs_id,2,50) @ abs_id
         abs_shp_date
         ad_name
         ad_line1
      with frame a.

      assign
         last_shipfrom = abs_shipfrom
         last_id       = substring(abs_id,2,50).

   end.

   for first poc_ctrl
      fields (poc_tol_cst poc_tol_pct)
   no-lock: end.

   mainloop:
   repeat:
/*GUI*/ if global-beam-me-up then undo, leave.


      do transaction:
/*GUI*/ if global-beam-me-up then undo, leave.


         for each sr_wkfl exclusive-lock where sr_userid = mfguser:
            delete sr_wkfl.
         end.

         {gprun.i ""gplotwdl.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


      end.
/*GUI*/ if global-beam-me-up then undo, leave.


      do transaction with frame a:
/*GUI*/ if global-beam-me-up then undo, leave.


         prompt-for
            abs_shipfrom abs_id
            abs_shp_date
         editing:

            if frame-field = "abs_shipfrom" then do:

               {mfnp05.i abs_mstr abs_id
                  "abs_id begins ""s"" and abs_type = ""r"" "
                  abs_shipfrom
                  "input abs_shipfrom"}

               if recno <> ? then do:

                  for first ad_mstr
                     fields (ad_addr ad_line1 ad_name)
                     where ad_addr = abs_shipfrom no-lock:
                  end. /* FOR FIRST AD_MSTR */

                  disp_abs_id = substring(abs_id,2,50).

                  display
                     abs_shipfrom
                     abs_shp_date
                     disp_abs_id @ abs_id
                     ad_name     when (available ad_mstr)
                     ""          when (not available ad_mstr) @ ad_name
                     ad_line1    when (available ad_mstr)
                     ""          when (not available ad_mstr) @ ad_line1.
               end.

            end.

            else
            if frame-field = "abs_id" then do:

               global_addr = input abs_shipfrom.

               {mfnp05.i abs_mstr abs_id
                  "abs_shipfrom = input abs_shipfrom and
                                  abs_id begins ""s""
                                  and abs_type = ""r"" "
                                  abs_id
                                  " ""s"" + input abs_id"}
               if recno <> ? then do:

                  for first ad_mstr
                     fields (ad_addr ad_line1 ad_name)
                     where ad_addr = abs_shipfrom no-lock:
                  end. /* FOR FIRST AD_MSTR */

                  disp_abs_id = substring(abs_id,2,50).

                  display
                     abs_shipfrom
                     abs_shp_date
                     disp_abs_id @ abs_id
                     ad_name     when (available ad_mstr)
                     ""          when (not available ad_mstr) @ ad_name
                     ad_line1    when (available ad_mstr)
                     ""          when (not available ad_mstr) @ ad_line1.
               end.

            end.

            else do:
               status input.
               readkey.
               apply lastkey.
            end.

         end.
/*GUI*/ if global-beam-me-up then undo, leave.


         for first vd_mstr
            fields (vd_addr)
            where vd_addr = input abs_shipfrom
         no-lock: end.

         if not available vd_mstr then do:
            /* Not a valid supplier */
            {pxmsg.i &MSGNUM=2 &ERRORLEVEL=3}
            next-prompt abs_shipfrom.
            undo, retry.
         end.

         for first ad_mstr
            fields (ad_addr ad_line1 ad_name)
            where ad_addr = input abs_shipfrom
         no-lock: end.

         display ad_name ad_line1.

         if input abs_id = "" then do:
            /* Shipper ID Required */
            {pxmsg.i &MSGNUM=8193 &ERRORLEVEL=3}
            next-prompt abs_id.
            undo, retry.
         end.

         assign
            last_shipfrom = input abs_shipfrom
            last_id       = input abs_id
            ship_abs_id   = input abs_id.

      end.

      do transaction:
/*GUI*/ if global-beam-me-up then undo, leave.


         find abs_mstr where
            abs_shipfrom = input frame a abs_shipfrom and
            abs_id = "s" + input frame a abs_id
         exclusive-lock no-error.

         if available abs_mstr and
            abs_type <> "r"
         then do:
            {pxmsg.i &MSGNUM=5814 &ERRORLEVEL=3}
            /* SELECTED SHIPPER HAS INVALID TYPE */
            next-prompt abs_id with frame a.
            undo mainloop, retry mainloop.
         end.

         if not available abs_mstr then do:

            {pxmsg.i &MSGNUM=1 &ERRORLEVEL=1}

            create abs_mstr.
            assign
               abs_shipfrom = input frame a abs_shipfrom
               abs_id       = "s" + input frame a abs_id
               abs_qty      = 1
               abs_shp_date = if input frame a abs_shp_date <> ? then
                                 input frame a abs_shp_date
                              else today
               abs_type     = "r".
         end.

         else do:
            /* IF CONFIRMED, WARN USER */
            if substring(abs_status,2,1) = "y" then do:
               {pxmsg.i &MSGNUM=8146 &ERRORLEVEL=3}
               /*SHIPPER PREVIOUSLY CONFIRMED*/
               undo mainloop, retry.
            end.
         end.

         global_recid = recid(abs_mstr).

         for first si_mstr
            fields (si_db si_desc si_site)
            where si_site = abs_shipto
         no-lock: end.
/*GUI*/ if global-beam-me-up then undo, leave.



         clear frame b.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame b = F-b-title.

         display
            abs_shipto
            si_desc when (available si_mstr)
         with frame b.

         if available si_mstr then do:
            {gprun.i ""gpsiver.p""
               "(input si_site,
                 input recid(si_mstr),
                 output return_int)"}
/*GUI*/ if global-beam-me-up then undo, leave.

         end.

         else do:
            {gprun.i ""gpsiver.p""
               "(input abs_shipto, input ?, output return_int)"}
/*GUI*/ if global-beam-me-up then undo, leave.

         end.
         if return_int = 0 then do:
            {pxmsg.i &MSGNUM=725 &ERRORLEVEL=3}
            /* USER DOES NOT HAVE ACCESS TO SITE */
            undo mainloop, retry mainloop.
         end.

         do for abs_mstr_par:

            find abs_mstr_par where
               abs_mstr_par.abs_shipfrom = abs_mstr.abs_shipfrom and
               abs_mstr_par.abs_id = abs_mstr.abs_par_id
            no-lock no-error.

            if available abs_mstr_par then do:
               /* This is subordinate to: # */
               {pxmsg.i &MSGNUM=8102 &ERRORLEVEL=1 &MSGARG1=abs_id}
            end.
         end.

         /* HANDLE CAN-FIND IDIOSYNCRASY WITH ADD'L CAN-FIND */
         if can-find(first abs_mstr_cont
            where abs_mstr_cont.abs_shipfrom = abs_mstr.abs_shipfrom
              and abs_mstr_cont.abs_par_id = abs_mstr.abs_id)
         or can-find(abs_mstr_cont
            where abs_mstr_cont.abs_shipfrom = abs_mstr.abs_shipfrom
              and abs_mstr_cont.abs_par_id = abs_mstr.abs_id)
         then do:
            /* Contents (container or item) exist */
            {pxmsg.i &MSGNUM=8103 &ERRORLEVEL=1}
         end.

         else do on error undo, retry
                 on endkey undo mainloop, retry mainloop
         with frame b:
/*GUI*/ if global-beam-me-up then undo, leave.

            {rsshmta.i}
         end.
/*GUI*/ if global-beam-me-up then undo, leave.


         abs_recid = recid(abs_mstr).

         if use-log-acctg then do:

            /* UPDATE CARRIER REFERENCE */
            {gprunmo.i &module = "LA" &program = "lacarref.p"
                       &param  = """(input abs_recid)"""}

         end.


      end.

      for first abs_mstr
         fields (abs_dataset abs_gwt abs_id abs_nwt abs_par_id abs_qty
                 abs_shipfrom abs_shipto abs_shp_date abs_status
                 abs_type abs_vol)
         where recid(abs_mstr) = abs_recid
      no-lock: end.

      assign
         old_nwt = abs_nwt
         old_gwt = abs_gwt
         old_vol = abs_vol.

      /* MAINTAIN CONTAINERS */
      {gprun.i ""rsshmta.p"" "(input abs_recid)"}
/*GUI*/ if global-beam-me-up then undo, leave.


      /* MAINTAIN ITEMS */
      {gprun.i ""rsshmtb.p"" "(input abs_recid)"}
/*GUI*/ if global-beam-me-up then undo, leave.


      /* EXPLODE SHIPPER TO GET ORDER DETAIL */
      for each work_abs_mstr exclusive-lock:
         delete work_abs_mstr.
      end.

      {gprun.i ""rcsoisa.p"" "(input recid(abs_mstr))"}
/*GUI*/ if global-beam-me-up then undo, leave.


      warn_substruct = no.

      {rsshmtt.i}

      global_recid = recid(abs_mstr).

      if use-log-acctg
      then do:

         /* UPDATE LOGISTICS SUPPLIER */
         {gprunmo.i &module = "LA" &program = "lalgsupp.p"
                    &param  = """(input substring(abs_id,2),
                                  input '{&TYPE_POShipper}',
                                  input yes,
                                  input abs_mstr.abs_shipfrom)"""}

      end. /* if use-log-acctg */

   end.

end. /* do for abs_mstr */

if is_wiplottrace_enabled() then
   delete PROCEDURE h_wiplottrace_procs no-error.
if is_wiplottrace_enabled() then
   delete PROCEDURE h_wiplottrace_funcs no-error.
